package com.EAsystem.mapper;

import com.EAsystem.entity.Attendance;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface AttendanceMapper {

    // 插入考勤记录
    int insertAttendance(Attendance attendance);



    // 更新考勤记录
    int updateAttendance(Attendance attendance);

    // 根据ID删除考勤记录
    int deleteAttendanceById(Long id);

    // 根据ID查询考勤记录
    Attendance findAttendanceById(Long id);



    // 分页查询所有考勤记录
    List<Attendance> findAllAttendancesWithPage();

    // 根据学生ID查询考勤记录
    List<Attendance> findAttendancesByStudentId(Integer studentId);









    // 根据条件查询考勤记录
    List<Attendance> findAttendancesByCondition(Attendance attendance);

    // 统计学生在某课程的出勤情况
    @MapKey("status")
    Map<String, Integer> countAttendanceStatusByStudentIdAndCourseId(@Param("studentId") Integer studentId, @Param("courseId") Integer courseId);
}